/*
 * RtpMedium.cpp
 *
 *  Created on: 2016年9月22日
 *      Author: zhengboyuan
 */


#include "RtpMedium.h"


const char*	RtpMedium::VIDEO = "video";
const char*	RtpMedium::AUDIO = "audio";

const char*	RtpMedium::H264 = "H264";
const char*	RtpMedium::H265 = "H265";
const char*	RtpMedium::PS = "PS";

const char*	RtpMedium::PCMA = "PCMA";
const char*	RtpMedium::PCMU = "PCMU";

const char*	RtpMedium::RTP_AVP = "RTP/AVP";
const char*	RtpMedium::RTP_AVP_TCP = "RTP/AVP/TCP";
const char*	RtpMedium::TCP_RTP_AVP = "TCP/RTP/AVP";


const char*	RtpMedium::passive = "passive";
const char*	RtpMedium::active = "active";



const char* RtpMedium::getModeName(int mode)
{
	switch (mode)
	{
	case kRecvOnly:
		return "recvonly";
	case kSendOnly:
		return "sendonly";
	case kSendRecv:
		return "sendrecv";
	default:
		return "";
	}
}

int RtpMedium::getPeerMode(int mode)
{
	if (mode == kRecvOnly)
	{
		return kSendOnly;
	}
	else if (mode == kSendOnly)
	{
		return kRecvOnly;
	}
	else if (mode == kSendRecv)
	{
		return kSendRecv;
	}
	return mode;
}

std::string RtpMedium::getPeerSetup(const std::string& setup)
{
	if (setup == RtpMedium::passive)
	{
		return RtpMedium::active;
	}
	else if (setup == RtpMedium::active)
	{
		return RtpMedium::passive;
	}
	return setup;
}

int RtpMedium::getPayload(const std::string& codec)
{
    if (codec == RtpMedium::PCMU)
    {
        return 0;
    }

    if (codec == RtpMedium::PCMA)
    {
        return 8;
    }

    if (codec == RtpMedium::H264)
    {
        return 98;
    }

    return 96;
}
